package lfm.mpr;

import java.util.ArrayList;

import db.AdminBaseDatosHelper;
import objects.Partido;
import objects.Puntos;
import adapter.AdapterListJornadas;
import adapter.AdapterListPartidos;
import adapter.AdapterListDetallePuntosJornadas;
import adapter.AdapterListPuntosJornadas;
import adapter.AdapterPuntos;
import android.app.Activity;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ListView;

public class PuntosActivity extends Activity {
	
	private String jornada_id;
	private ListView listView_puntos;
	public static ArrayList<Puntos> list_puntos;
	private AdminBaseDatosHelper miBBDDHelper;
	private AdapterPuntos adapter_puntos;
	public static EditText filterText;
	
	public void onCreate(Bundle savedInstanceState) {
		 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_puntos_jornada);
       
        listView_puntos = (ListView) findViewById(R.id.listView_puntos_jornada);
        filterText = (EditText) findViewById(R.id.editText_search_puntos);
        
        listView_puntos.setFastScrollEnabled(true); 
        int[] colors = {0, 0xFFFF0000, 0}; // red for the example
        listView_puntos.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
        listView_puntos.setDividerHeight(3);
     
        list_puntos = AdapterListPuntosJornadas.list_puntos_jornada;
        
        adapter_puntos = new AdapterPuntos(PuntosActivity.this, list_puntos);
        listView_puntos.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView_puntos.setAdapter(adapter_puntos);
        adapter_puntos.notifyDataSetChanged();
        
        filterText.setOnKeyListener(new OnKeyListener() {
  	      public boolean onKey(View v, int keyCode, KeyEvent event) {
  	          if (keyCode  == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
  	        	  //Log.i("LFM_Log","TEXTO A BUSCAR " + filterText.getText().toString());
  	        	  adapter_puntos.getFilter().filter(filterText.getText().toString());
  	        	  InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
  	        	  imm.hideSoftInputFromWindow(filterText.getWindowToken(), 0);
  	        	  return true;
  	          }
  	          else return false;
  	      }

  	  });
        
       
	}

}//end_PartidosActivity
